/******************************************************************************
 * * contact_edit.c - implementation of contact edit functions
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#include "contact_global.h"

/**
 * Delete one contact
 * param (in) ContactInfo: Contacts_Info_t *
 * return  VOID
 */
VOID Contacts_Delete_One_Contact(Contacts_Info_t *ContactInfo)
{
    lv_ll_t           *ContactsList;
    Contacts_List_t   *Contact;
    UINT8             Memory;
    UINT16            Index;
    UINT8             Bit;
    UINT8             NvBitmap;

    UI_Log_Out(UI_SUB_MODULE_FRAMEWORK, UI_LOG_LEVEL_TRACE_1, "Contacts_Delete_One_Contact, Name %s, Number %s\n", ContactInfo->Name, ContactInfo->Number);

    /* Delete contact from speed dial list */
    Contacts_Speed_Dials_Update_Contact(ContactInfo, NULL, NULL);

    ContactsList = &g_ContactsMng.ContactsList;
    Contact      = _lv_ll_get_head(ContactsList);
    while (NULL != Contact)
    {
        if (ContactInfo == Contact->ContactInfo)
        {
            _lv_ll_remove(ContactsList, Contact);
            Hal_Mem_Free(Contact);
            g_ContactsMng.ContactsCount--;
            UI_Log_Out(UI_SUB_MODULE_FRAMEWORK, UI_LOG_LEVEL_TRACE_1, "Contacts_Delete_One_Contact, Contact count %d\n", g_ContactsMng.ContactsCount);
            break;
        }
        Contact = _lv_ll_get_next(ContactsList, Contact);
    }

    Memory = Contacts_Get_Contact_Memory(ContactInfo->MemoryAndIndex);
    if (CONTACTS_MEMSEL_ALL != g_ContactsMng.ContactsMemSel.MemSel)
    {
        if (0 != (g_ContactsMng.ContactsMemSel.MemSel & Contacts_Get_Memory_Select(Memory)))
        {
            ContactsList = &g_ContactsMng.ContactsMemSel.ListForSpecMem;
            Contact      = _lv_ll_get_head(ContactsList);
            while (NULL != Contact)
            {
                if (ContactInfo == Contact->ContactInfo)
                {
                    _lv_ll_remove(ContactsList, Contact);
                    Hal_Mem_Free(Contact);
                    g_ContactsMng.ContactsMemSel.ContactsCount--;
                    break;
                }
                Contact = _lv_ll_get_next(ContactsList, Contact);
            }
        }
    }

    Index = Contacts_Get_Contact_Index(ContactInfo->MemoryAndIndex);
    g_ContactsMng.PhkStatus[Memory].Used--;
    if (CONTACTS_MEMORY_PHONE == Memory)
    {
        Bit   = Index % 8;
        Index = Index / 8;
        if (1 != UI_NV_Read_Req(NV_SECTION_UI_CONTACTS_BITMAP, Index, 1, &NvBitmap))
        {
            /* error */
            return;
        }
        NvBitmap &= ~(0x01 << Bit);
        if (1 != UI_NV_Write_Req(NV_SECTION_UI_CONTACTS_BITMAP, Index, 1, &NvBitmap))
        {
            /* error */
            return;
        }
    }
    else
    {
        Contacts_Send_Write_Phonebook_Req(Memory, NULL, NULL, Index);
    }

    Hal_Mem_Free(ContactInfo);
} /* Contacts_Delete_One_Contact */

/**
 * Callback function for handling key pressed on Contacts_Details_Delete interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
UINT8 Contacts_Details_Delete_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    Contacts_Info_t *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTRIGHT:
            Nav_Back(ACT_ID_ANY);
            break;

        case KEY_END:
            Nav_Home(ACT_ID_ANY);
            break;

        case KEY_OK: // delete
            Contacts_Delete_One_Contact(Contact);
            Contacts_Reset_Contacts_Interface();
            Contacts_Create_Contacts_Deleted();
            break;

        default:
            break;
        } /* switch */
    }

    return(1);
} /* Contacts_Details_Delete_Key_Cb */

/**
 * Create Contacts_Details_Delete interface
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Create_Contacts_Details_Delete(VOID)
{
    UI_Normal_NoTitle_Desc_t *Interface;
    Nav_Func_List_t          FuncList;

    Interface = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(Interface, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS_DELETE;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)Interface;

    Interface->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DELETE_Q;
    Interface->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    Interface->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    Interface->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    Interface->ButtonBar.ButtonL.Valid = FALSE;

    Interface->ButtonBar.ButtonM.Valid = TRUE;
    Interface->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;

    Interface->ButtonBar.ButtonR.Valid = TRUE;
    Interface->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    Interface->KeyFunc = Contacts_Details_Delete_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_NoTitle_Create;
    FuncList.OnDestroy = Contacts_Interface_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_DETAILS_DELETE, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
}

/**
 * Callback function for handling key pressed on Contacts_Details_Moving interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
UINT8 Contacts_Details_Moving_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTRIGHT: // quit
            break;

        case KEY_END:
            Nav_Home(ACT_ID_ANY);
            break;

        default:
            break;
        } /* switch */
    }

    return(1);
}

/**
 * Create Contacts_Details_Moving interface
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Create_Contacts_Details_Moving(VOID)
{
    UI_Normal_NoTitle_Desc_t *Interface;
    Nav_Func_List_t          FuncList;

    Interface = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(Interface, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS_MOVING;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)Interface;

    Interface->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_MOVING;
    Interface->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    Interface->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    Interface->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    Interface->ContenCont.ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;
    Interface->ContenCont.ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    /* Interface->ContenCont.ContImg.Img = ; */

    Interface->ButtonBar.ButtonL.Valid = FALSE;
    Interface->ButtonBar.ButtonM.Valid = FALSE;
    Interface->ButtonBar.ButtonR.Valid = TRUE;
    Interface->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_QUIT;

    Interface->KeyFunc = Contacts_Details_Moving_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_NoTitle_Create;
    FuncList.OnDestroy = Contacts_Interface_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_DETAILS_MOVING, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
}

/**
 * Action if pressing phone button on Contacts_Details_Move interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Move_Btn_Phone_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Info_t *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
    Contacts_Info_t *ContactInfo;

    if (g_ContactsMng.PhkStatus[CONTACTS_MEMORY_PHONE].Used ==
        g_ContactsMng.PhkStatus[CONTACTS_MEMORY_PHONE].Total)
    {
        Contacts_Create_Contacts_Full();
        return;
    }

    Contacts_Create_Contacts_Details_Moving();

    ContactInfo = (Contacts_Info_t *)Hal_Mem_Alloc(sizeof(Contacts_Info_t));
    Hal_Mem_Copy(ContactInfo, Contact, sizeof(Contacts_Info_t));
    ContactInfo->MemoryAndIndex = Contacts_Set_Contact_Memory(CONTACTS_MEMORY_PHONE);
    ContactInfo->ToneIndex      = IF_CONTACTS_DEFAULT_TONE;

    Contacts_Add_Contact_With_Name_Modified(ContactInfo, &g_ContactsMng.InterfaceCtrl.FocusContact);

    Contacts_Add_Contact_To_Nvm(ContactInfo);

    Contacts_Delete_One_Contact(Contact);

    Contacts_Update_Contacts_Interface();

    Contacts_Create_Contacts_Moved();
}

/**
 * Action if pressing SIM1 button on Contacts_Details_Move interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Move_Btn_Sim1_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Info_t   *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
    Contacts_Info_t   *ContactInfo;

    if (g_ContactsMng.PhkStatus[CONTACTS_MEMORY_SIM1].Used ==
        g_ContactsMng.PhkStatus[CONTACTS_MEMORY_SIM1].Total)
    {
        Contacts_Create_Contacts_Full();
        return;
    }

    Contacts_Create_Contacts_Details_Moving();

    ContactInfo = (Contacts_Info_t *)Hal_Mem_Alloc(sizeof(Contacts_Info_t));
    Hal_Mem_Copy(ContactInfo, Contact, sizeof(Contacts_Info_t));
    ContactInfo->MemoryAndIndex = Contacts_Set_Contact_Memory(CONTACTS_MEMORY_SIM1);
    ContactInfo->ToneIndex      = IF_CONTACTS_DEFAULT_TONE;

    Contacts_Add_Contact_With_Name_Modified(ContactInfo, &g_ContactsMng.InterfaceCtrl.FocusContact);

    Contacts_Send_Write_Phonebook_Req(CONTACTS_MEMORY_SIM1,
                                      ContactInfo->Name,
                                      ContactInfo->Number,
                                      MMI_MODEM_CONTACT_INDEX_INVALID);

    Contacts_Delete_One_Contact(Contact);

    Contacts_Update_Contacts_Interface();

    Contacts_Create_Contacts_Moved();
}

/**
 * Action if pressing SIM2 button on Contacts_Details_Move interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Move_Btn_Sim2_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Info_t   *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
    Contacts_Info_t   *ContactInfo;

    if (g_ContactsMng.PhkStatus[CONTACTS_MEMORY_SIM2].Used ==
        g_ContactsMng.PhkStatus[CONTACTS_MEMORY_SIM2].Total)
    {
        Contacts_Create_Contacts_Full();
        return;
    }

    Contacts_Create_Contacts_Details_Moving();

    ContactInfo = (Contacts_Info_t *)Hal_Mem_Alloc(sizeof(Contacts_Info_t));
    Hal_Mem_Copy(ContactInfo, Contact, sizeof(Contacts_Info_t));
    ContactInfo->MemoryAndIndex = Contacts_Set_Contact_Memory(CONTACTS_MEMORY_SIM2);
    ContactInfo->ToneIndex      = IF_CONTACTS_DEFAULT_TONE;

    Contacts_Add_Contact_With_Name_Modified(ContactInfo, &g_ContactsMng.InterfaceCtrl.FocusContact);

    Contacts_Send_Write_Phonebook_Req(CONTACTS_MEMORY_SIM2,
                                      ContactInfo->Name,
                                      ContactInfo->Number,
                                      MMI_MODEM_CONTACT_INDEX_INVALID);

    Contacts_Delete_One_Contact(Contact);

    Contacts_Update_Contacts_Interface();

    Contacts_Create_Contacts_Moved();
}

/**
 * Callback function for restoring state on Contacts_Details_Move interface after backward from another activity
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Details_Move_OnRestoreState(VOID *Ctrl)
{
    g_ContactsMng.InterfaceCtrl.Ctrl        = Ctrl;
    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS_MOVE;
}

/**
 * Create Contacts_Details_Move interface
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Create_Contacts_Details_Move(VOID)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc;
    Nav_Func_List_t            FuncList;
    UINT8                      Memory;
    UINT8                      i      = 0;
    UINT8                      Bitmap = 0;
    UINT32                     Len;

    Memory = Contacts_Get_Contact_Memory(g_ContactsMng.InterfaceCtrl.ContactDetail->MemoryAndIndex);

    NormalLstOnlyDesc =
        (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(NormalLstOnlyDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS_MOVE;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)NormalLstOnlyDesc;

    NormalLstOnlyDesc->TitleBar.TxtId      = PHONE_TEXT_ID_MOVE;
    NormalLstOnlyDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    NormalLstOnlyDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    if (CONTACTS_MEMORY_PHONE == Memory)
    {
        if (CONTACTS_PHONEBOOK_STATUS_SIM_ABSENT != g_ContactsMng.PhonebookStatus[0])
        {
            NormalLstOnlyDesc->List.ListButtonCnt++;
            Bitmap |= CONTACTS_MEMSEL_SIM1;
        }
        if (CONTACTS_PHONEBOOK_STATUS_SIM_ABSENT != g_ContactsMng.PhonebookStatus[1])
        {
            NormalLstOnlyDesc->List.ListButtonCnt++;
            Bitmap |= CONTACTS_MEMSEL_SIM2;
        }
    }
    else
    {
        NormalLstOnlyDesc->List.ListButtonCnt++;
        Bitmap |= CONTACTS_MEMSEL_PHONE;

        if (CONTACTS_MEMORY_SIM1 == Memory)
        {
            if (CONTACTS_PHONEBOOK_STATUS_SIM_ABSENT != g_ContactsMng.PhonebookStatus[1])
            {
                NormalLstOnlyDesc->List.ListButtonCnt++;
                Bitmap |= CONTACTS_MEMSEL_SIM2;
            }
        }
        else
        {
            if (CONTACTS_PHONEBOOK_STATUS_SIM_ABSENT != g_ContactsMng.PhonebookStatus[0])
            {
                NormalLstOnlyDesc->List.ListButtonCnt++;
                Bitmap |= CONTACTS_MEMSEL_SIM1;
            }
        }
    }
    Len = sizeof(UI_Button_Desc_t) * NormalLstOnlyDesc->List.ListButtonCnt;
    NormalLstOnlyDesc->List.ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(Len);
    Hal_Mem_Set(NormalLstOnlyDesc->List.ButtonList, 0, Len);

    if (0 != (Bitmap & CONTACTS_MEMSEL_PHONE))
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_PHONE;
        NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun = Contacts_Details_Move_Btn_Phone_Cb;
    }
    if (0 != (Bitmap & CONTACTS_MEMSEL_SIM1))
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_SIM1;
        NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun = Contacts_Details_Move_Btn_Sim1_Cb;
    }
    if (0 != (Bitmap & CONTACTS_MEMSEL_SIM2))
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_SIM2;
        NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun = Contacts_Details_Move_Btn_Sim2_Cb;
    }

    NormalLstOnlyDesc->BtnBar.ButtonL.Valid = FALSE;
    NormalLstOnlyDesc->BtnBar.ButtonM.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    NormalLstOnlyDesc->BtnBar.ButtonR.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalLstOnlyDesc->KeyFunc = Contacts_Normal_List_Interface_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Normal_List_Only_Create;
    FuncList.OnRestoreState = Contacts_Details_Move_OnRestoreState;
    FuncList.OnDestroy      = Contacts_Normal_List_Interface_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_DETAILS_MOVE, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
} /* Contacts_Create_Contacts_Details_Move */

/**
 * Callback function for handling key pressed on Contacts_Details_Copying interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
UINT8 Contacts_Details_Copying_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTRIGHT: // quit
            break;

        case KEY_END:
            Nav_Home(ACT_ID_ANY);
            break;

        default:
            break;
        } /* switch */
    }

    return(1);
}

/**
 * Create Contacts_Details_Copying interface
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Create_Contacts_Details_Copying(VOID)
{
    UI_Normal_NoTitle_Desc_t *Interface;
    Nav_Func_List_t          FuncList;

    Interface = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(Interface, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS_COPYING;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)Interface;

    Interface->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_COPYING;
    Interface->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    Interface->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    Interface->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    Interface->ContenCont.ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;
    Interface->ContenCont.ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    /* Interface->ContenCont.ContImg.Img = ; */

    Interface->ButtonBar.ButtonL.Valid = FALSE;
    Interface->ButtonBar.ButtonM.Valid = FALSE;
    Interface->ButtonBar.ButtonR.Valid = TRUE;
    Interface->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_QUIT;

    Interface->KeyFunc = Contacts_Details_Copying_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_NoTitle_Create;
    FuncList.OnDestroy = Contacts_Interface_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_DETAILS_COPYING, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
}

/**
 * Action if pressing phone button on Contacts_Details_Copy interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Copy_Btn_Phone_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Info_t *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
    Contacts_Info_t *ContactInfo;

    if (g_ContactsMng.PhkStatus[CONTACTS_MEMORY_PHONE].Used ==
        g_ContactsMng.PhkStatus[CONTACTS_MEMORY_PHONE].Total)
    {
        Contacts_Create_Contacts_Full();
        return;
    }

    Contacts_Create_Contacts_Details_Copying();

    ContactInfo = (Contacts_Info_t *)Hal_Mem_Alloc(sizeof(Contacts_Info_t));
    Hal_Mem_Copy(ContactInfo, Contact, sizeof(Contacts_Info_t));
    ContactInfo->MemoryAndIndex = Contacts_Set_Contact_Memory(CONTACTS_MEMORY_PHONE);
    ContactInfo->ToneIndex      = IF_CONTACTS_DEFAULT_TONE;

    Contacts_Add_Contact_With_Name_Modified(ContactInfo, NULL);

    Contacts_Add_Contact_To_Nvm(ContactInfo);

    Contacts_Update_Contacts_Interface();

    Contacts_Create_Contacts_Copied();
} /* Contacts_Details_Copy_Btn_Phone_Cb */

/**
 * Action if pressing SIM1 button on Contacts_Details_Copy interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Copy_Btn_Sim1_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Info_t   *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
    Contacts_Info_t   *ContactInfo;

    if (g_ContactsMng.PhkStatus[CONTACTS_MEMORY_SIM1].Used ==
        g_ContactsMng.PhkStatus[CONTACTS_MEMORY_SIM1].Total)
    {
        Contacts_Create_Contacts_Full();
        return;
    }

    Contacts_Create_Contacts_Details_Copying();

    ContactInfo = (Contacts_Info_t *)Hal_Mem_Alloc(sizeof(Contacts_Info_t));
    Hal_Mem_Copy(ContactInfo, Contact, sizeof(Contacts_Info_t));
    ContactInfo->MemoryAndIndex = Contacts_Set_Contact_Memory(CONTACTS_MEMORY_SIM1);
    ContactInfo->ToneIndex      = IF_CONTACTS_DEFAULT_TONE;

    Contacts_Add_Contact_With_Name_Modified(ContactInfo, NULL);

    Contacts_Send_Write_Phonebook_Req(CONTACTS_MEMORY_SIM1,
                                      ContactInfo->Name,
                                      ContactInfo->Number,
                                      MMI_MODEM_CONTACT_INDEX_INVALID);

    Contacts_Update_Contacts_Interface();

    Contacts_Create_Contacts_Copied();
}

/**
 * Action if pressing SIM2 button on Contacts_Details_Copy interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Copy_Btn_Sim2_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Info_t   *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
    Contacts_Info_t   *ContactInfo;

    if (g_ContactsMng.PhkStatus[CONTACTS_MEMORY_SIM2].Used ==
        g_ContactsMng.PhkStatus[CONTACTS_MEMORY_SIM2].Total)
    {
        Contacts_Create_Contacts_Full();
        return;
    }

    Contacts_Create_Contacts_Details_Copying();

    ContactInfo = (Contacts_Info_t *)Hal_Mem_Alloc(sizeof(Contacts_Info_t));
    Hal_Mem_Copy(ContactInfo, Contact, sizeof(Contacts_Info_t));
    ContactInfo->MemoryAndIndex = Contacts_Set_Contact_Memory(CONTACTS_MEMORY_SIM2);
    ContactInfo->ToneIndex      = IF_CONTACTS_DEFAULT_TONE;

    Contacts_Add_Contact_With_Name_Modified(ContactInfo, NULL);

    Contacts_Send_Write_Phonebook_Req(CONTACTS_MEMORY_SIM2,
                                      ContactInfo->Name,
                                      ContactInfo->Number,
                                      MMI_MODEM_CONTACT_INDEX_INVALID);

    Contacts_Update_Contacts_Interface();

    Contacts_Create_Contacts_Copied();
}

/**
 * Callback function for restoring state on Contacts_Details_Copy interface after backward from another activity
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Details_Copy_OnRestoreState(VOID *Ctrl)
{
    g_ContactsMng.InterfaceCtrl.Ctrl        = Ctrl;
    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS_COPY;
}

/**
 * Create Contacts_Details_Copy interface
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Create_Contacts_Details_Copy(VOID)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc;
    Nav_Func_List_t            FuncList;
    UINT8                      Memory;
    UINT8                      i      = 0;
    UINT8                      Bitmap = 0;
    UINT32                     Len;

    Memory = Contacts_Get_Contact_Memory(g_ContactsMng.InterfaceCtrl.ContactDetail->MemoryAndIndex);

    NormalLstOnlyDesc =
        (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(NormalLstOnlyDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS_COPY;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)NormalLstOnlyDesc;

    NormalLstOnlyDesc->TitleBar.TxtId      = PHONE_TEXT_ID_COPY;
    NormalLstOnlyDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    NormalLstOnlyDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    if (CONTACTS_MEMORY_PHONE == Memory)
    {
        if (CONTACTS_PHONEBOOK_STATUS_SIM_ABSENT != g_ContactsMng.PhonebookStatus[0])
        {
            NormalLstOnlyDesc->List.ListButtonCnt++;
            Bitmap |= CONTACTS_MEMSEL_SIM1;
        }
        if (CONTACTS_PHONEBOOK_STATUS_SIM_ABSENT != g_ContactsMng.PhonebookStatus[1])
        {
            NormalLstOnlyDesc->List.ListButtonCnt++;
            Bitmap |= CONTACTS_MEMSEL_SIM2;
        }
    }
    else
    {
        NormalLstOnlyDesc->List.ListButtonCnt++;
        Bitmap |= CONTACTS_MEMSEL_PHONE;

        if (CONTACTS_MEMORY_SIM1 == Memory)
        {
            if (CONTACTS_PHONEBOOK_STATUS_SIM_ABSENT != g_ContactsMng.PhonebookStatus[1])
            {
                NormalLstOnlyDesc->List.ListButtonCnt++;
                Bitmap |= CONTACTS_MEMSEL_SIM2;
            }
        }
        else
        {
            if (CONTACTS_PHONEBOOK_STATUS_SIM_ABSENT != g_ContactsMng.PhonebookStatus[0])
            {
                NormalLstOnlyDesc->List.ListButtonCnt++;
                Bitmap |= CONTACTS_MEMSEL_SIM1;
            }
        }
    }
    Len = sizeof(UI_Button_Desc_t) * NormalLstOnlyDesc->List.ListButtonCnt;
    NormalLstOnlyDesc->List.ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(Len);
    Hal_Mem_Set(NormalLstOnlyDesc->List.ButtonList, 0, Len);

    if (0 != (Bitmap & CONTACTS_MEMSEL_PHONE))
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_PHONE;
        NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun = Contacts_Details_Copy_Btn_Phone_Cb;
    }
    if (0 != (Bitmap & CONTACTS_MEMSEL_SIM1))
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_SIM1;
        NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun = Contacts_Details_Copy_Btn_Sim1_Cb;
    }
    if (0 != (Bitmap & CONTACTS_MEMSEL_SIM2))
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_SIM2;
        NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun = Contacts_Details_Copy_Btn_Sim2_Cb;
    }

    NormalLstOnlyDesc->BtnBar.ButtonL.Valid = FALSE;
    NormalLstOnlyDesc->BtnBar.ButtonM.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    NormalLstOnlyDesc->BtnBar.ButtonR.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalLstOnlyDesc->KeyFunc = Contacts_Normal_List_Interface_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Normal_List_Only_Create;
    FuncList.OnRestoreState = Contacts_Details_Copy_OnRestoreState;
    FuncList.OnDestroy      = Contacts_Normal_List_Interface_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_DETAILS_COPY, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
} /* Contacts_Create_Contacts_Details_Copy */

/**
 * Create Contacts_Ring_Tone_Selected interface
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Create_Contacts_Ring_Tone_Selected(VOID)
{
    UI_Status_Desc_t *StatusDesc;
    Nav_Func_List_t  FuncList;

    StatusDesc = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(StatusDesc, 0, sizeof(UI_Status_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_RING_TONE_SELECTED;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)StatusDesc;

    StatusDesc->ContLabel.TxtId      = PHONE_TEXT_ID_TONE_SEL_FOR_CONTACT;
    StatusDesc->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    StatusDesc->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    StatusDesc->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    StatusDesc->ContImg.Img  = SYMBOL_CHECKED;
    StatusDesc->ContImgAlign = LV_ALIGN_IN_TOP_RIGHT;

    StatusDesc->KeyFunc = Contacts_Status_Interface_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Status_Create;
    FuncList.OnCreate  = Contacts_Status_Interface_OnCreate;
    FuncList.OnDestroy = Contacts_Interface_OnDestroy;

    Nav_Backward_And_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_DETAILS, ACT_ID_CONTACTS_RING_TONE_SELECTED, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
}

/**
 * Action if pressing tone button on Contacts_Ring_Tone interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Ring_Tone_Btn_Tone_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    UI_List_Desc_t  *List =
        &(((UI_Normal_List_Only_Desc_t *)g_ContactsMng.InterfaceCtrl.Ctrl)->List);
    Contacts_Info_t *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
    UINT32          Offset;
    UINT16          Index = 0;
    Contacts_List_t *ContactsList;
    UINT8           ToneIndex;

    if (0 == List->Index)
    {
        ToneIndex = IF_CONTACTS_NO_TONE;
    }
    else
    {
        ToneIndex = List->Index - 1;
    }
    
    if (ToneIndex != Contact->ToneIndex) // tone changed
    {
        Contact->ToneIndex = ToneIndex;

        ContactsList = _lv_ll_get_head(&g_ContactsMng.ContactsList);
        while (NULL != ContactsList)
        {
            if (Contact == ContactsList->ContactInfo)
            {
                break;
            }
            ContactsList = _lv_ll_get_next(&g_ContactsMng.ContactsList, ContactsList);
            Index++;
        }

        Offset = sizeof(NV_UI_Contacts_Contact_Info_t) * Index + NV_CONTACTS_MAX_NAME_LEN +
                 NV_CONTACTS_MAX_NUMBER_LEN;
        if (1 != UI_NV_Write_Req(NV_SECTION_UI_CONTACTS_LIST, Offset, 1, &Contact->ToneIndex))
        {
            /* error */
            return;
        }
    }

    Contacts_Create_Contacts_Ring_Tone_Selected();
} /* Contacts_Ring_Tone_Btn_Tone_Cb */

/**
 * Callback function for handling key pressed on Contacts_Ring_Tone interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
UINT8 Contacts_Ring_Tone_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UI_List_Desc_t         *List =
        &(((UI_Normal_List_Only_Desc_t *)g_ContactsMng.InterfaceCtrl.Ctrl)->List);
    UINT8                  Ret = 1;   // not call default key function for List
    If_Setting_Play_Tone_t *PlayTone;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTRIGHT:
            /* Stop tone  */
            printf("%s: stop tone, key %d\n", __FUNCTION__, Key_Val);
            PlayTone =
                (If_Setting_Play_Tone_t *)Hal_Mem_Alloc(sizeof(If_Setting_Play_Tone_t));
            PlayTone->PlayCtrl = IF_SETTING_PLAY_TONS_STOP;
            PlayTone->ToneType = IF_SETTING_TONS_TYPE_CONTACTS;
            Setting_Play_Tone_Req(PlayTone);

            Nav_Back(ACT_ID_ANY);
            break;

        case KEY_END:
            /* Stop tone  */
            printf("%s: stop tone, key %d\n", __FUNCTION__, Key_Val);
            PlayTone =
                (If_Setting_Play_Tone_t *)Hal_Mem_Alloc(sizeof(If_Setting_Play_Tone_t));
            PlayTone->PlayCtrl = IF_SETTING_PLAY_TONS_STOP;
            PlayTone->ToneType = IF_SETTING_TONS_TYPE_CONTACTS;
            Setting_Play_Tone_Req(PlayTone);

            Nav_Home(ACT_ID_ANY);
            break;

        case KEY_OK:
            Ret = 0; // call default key function for List
            break;

        case KEY_UP:
        case KEY_DOWN:
        case KEY_LEFT:
        case KEY_RIGHT:
            /* Stop tone  */
            printf("%s: stop tone, key %d\n", __FUNCTION__, Key_Val);
            PlayTone =
                (If_Setting_Play_Tone_t *)Hal_Mem_Alloc(sizeof(If_Setting_Play_Tone_t));
            PlayTone->PlayCtrl = IF_SETTING_PLAY_TONS_STOP;
            PlayTone->ToneType = IF_SETTING_TONS_TYPE_CONTACTS;
            Setting_Play_Tone_Req(PlayTone);

            Contacts_Press_Direction_Key_On_List(Key_Val);

            if (0 != List->Index)
            {
                /* play tone  */
                PlayTone =
                    (If_Setting_Play_Tone_t *)Hal_Mem_Alloc(sizeof(If_Setting_Play_Tone_t));
                PlayTone->PlayCtrl      = IF_SETTING_PLAY_TONS_START;
                PlayTone->ToneType      = IF_SETTING_TONS_TYPE_CONTACTS;
                PlayTone->SpecToneIndex = List->Index - 1;
                Setting_Play_Tone_Req(PlayTone);
            }

            Ret = 0; // call default key function for List
            break;

        default:
            break;
        } /* switch */
    }

    return(Ret);
} /* Contacts_Ring_Tone_Key_Cb */

/**
 * Callback function for saving state on Contacts_Ring_Tone interface before forward to another activity
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Ring_Tone_OnSaveState(VOID *Ctrl)
{
    UI_List_Desc_t         *List =
        &(((UI_Normal_List_Only_Desc_t *)g_ContactsMng.InterfaceCtrl.Ctrl)->List);
    If_Setting_Play_Tone_t *PlayTone;

    /* Stop tone  */
    printf("%s: stop tone\n", __FUNCTION__);
    PlayTone =
        (If_Setting_Play_Tone_t *)Hal_Mem_Alloc(sizeof(If_Setting_Play_Tone_t));
    PlayTone->PlayCtrl      = IF_SETTING_PLAY_TONS_STOP;
    PlayTone->ToneType      = IF_SETTING_TONS_TYPE_CONTACTS;
    PlayTone->SpecToneIndex = List->Index;
    Setting_Play_Tone_Req(PlayTone);
}

/**
 * Callback function for restoring state on Contacts_Ring_Tone interface after backward from another activity
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Ring_Tone_OnRestoreState(VOID *Ctrl)
{
    g_ContactsMng.InterfaceCtrl.Ctrl        = Ctrl;
    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_RING_TONE;
}

/**
 * Create Contacts_Ring_Tone interface
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Create_Contacts_Ring_Tone(VOID)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc;
    Nav_Func_List_t            FuncList;
    If_Setting_Tone_List_t     *ToneList;
    UINT8                      i;
    UINT32                     Len;

    ToneList = Setting_Get_Tone_List_Req();
    if (NULL == ToneList)
    {
        /* error */
        return;
    }

    NormalLstOnlyDesc =
        (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(NormalLstOnlyDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_RING_TONE;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)NormalLstOnlyDesc;

    NormalLstOnlyDesc->TitleBar.TxtId      = PHONE_TEXT_ID_RINGING_TONE;
    NormalLstOnlyDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    NormalLstOnlyDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    NormalLstOnlyDesc->List.ListButtonCnt = 1 + ToneList->RingNameCnt;
    Len                                   = sizeof(UI_Button_Desc_t) *
                                            NormalLstOnlyDesc->List.ListButtonCnt;
    NormalLstOnlyDesc->List.ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(Len);
    Hal_Mem_Set(NormalLstOnlyDesc->List.ButtonList, 0, Len);

    NormalLstOnlyDesc->List.ButtonList[0].Valid       = TRUE;
    NormalLstOnlyDesc->List.ButtonList[0].ButtonIndex = 0;
    NormalLstOnlyDesc->List.ButtonList[0].TxtId       = PHONE_TEXT_ID_NO_TONE;
    NormalLstOnlyDesc->List.ButtonList[0].ReleaseFun  = Contacts_Ring_Tone_Btn_Tone_Cb;
    for (i = 1; i < NormalLstOnlyDesc->List.ListButtonCnt; i++)
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid       = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        NormalLstOnlyDesc->List.ButtonList[i].BtnTxt      = (INT8 *)Hal_Mem_Alloc(IF_SETTING_MAX_NAME_LEN);
        Hal_Mem_Copy(NormalLstOnlyDesc->List.ButtonList[i].BtnTxt, ToneList[i - 1].RingName, IF_SETTING_MAX_NAME_LEN);
        NormalLstOnlyDesc->List.ButtonList[i].ReleaseFun = Contacts_Ring_Tone_Btn_Tone_Cb;
    }

    if ((IF_CONTACTS_NO_TONE != g_ContactsMng.InterfaceCtrl.ContactDetail->ToneIndex)
        || (IF_CONTACTS_DEFAULT_TONE != g_ContactsMng.InterfaceCtrl.ContactDetail->ToneIndex))
    {
        NormalLstOnlyDesc->List.Index = g_ContactsMng.InterfaceCtrl.ContactDetail->ToneIndex + 1;
    }

    Hal_Mem_Free(ToneList);

    NormalLstOnlyDesc->BtnBar.ButtonL.Valid = FALSE;
    NormalLstOnlyDesc->BtnBar.ButtonM.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;
    NormalLstOnlyDesc->BtnBar.ButtonR.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalLstOnlyDesc->KeyFunc = Contacts_Ring_Tone_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Normal_List_Only_Create;
    FuncList.OnSaveState    = Contacts_Ring_Tone_OnSaveState;
    FuncList.OnRestoreState = Contacts_Ring_Tone_OnRestoreState;
    FuncList.OnDestroy      = Contacts_Normal_List_Interface_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_RING_TONE, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
} /* Contacts_Create_Contacts_Ring_Tone */

/**
 * Create Contacts_Ring_Tone_Not_Set interface
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Create_Contacts_Ring_Tone_Not_Set(VOID)
{
    UI_Status_Desc_t *StatusDesc;
    Nav_Func_List_t  FuncList;

    StatusDesc = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(StatusDesc, 0, sizeof(UI_Status_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_RING_TONE_NOT_SET;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)StatusDesc;

    StatusDesc->ContLabel.TxtId      = PHONE_TEXT_ID_NOT_SUPP_ON_SIM;
    StatusDesc->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    StatusDesc->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    StatusDesc->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    StatusDesc->ContImg.Img  = LV_SYMBOL_WARNING;
    StatusDesc->ContImgAlign = LV_ALIGN_IN_TOP_RIGHT;

    StatusDesc->KeyFunc = Contacts_Status_Interface_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Status_Create;
    FuncList.OnCreate  = Contacts_Status_Interface_OnCreate;
    FuncList.OnDestroy = Contacts_Interface_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_RING_TONE_NOT_SET, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
}

/**
 * Action if pressing call button on Contacts_Details_Option interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Option_Btn_Call_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    INT8            *Name;
    INT8            *Number;
    UINT8           Len;
    Contacts_Info_t *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;

    Len = strlen(Contact->Number);
    if (0 == Len)
    {
        Contacts_Create_No_Phone_Number();
        return;
    }
    Len++;
    Number = (INT8 *)Hal_Mem_Alloc(Len);
    Hal_Mem_Copy(Number, Contact->Number, Len);

    Len  = strlen(Contact->Name) + 1;
    Name = (INT8 *)Hal_Mem_Alloc(Len);
    Hal_Mem_Copy(Name, Contact->Name, Len);

    Contacts_Call_Req(Name, Number);
}

/**
 * Action if pressing send message button on Contacts_Details_Option interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Option_Btn_Send_Message_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    INT8            *Name;
    INT8            *Number;
    UINT8           Len;
    Contacts_Info_t *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;

    Len  = strlen(Contact->Name) + 1;
    Name = (INT8 *)Hal_Mem_Alloc(Len);
    Hal_Mem_Copy(Name, Contact->Name, Len);

    Len    = strlen(Contact->Number) + 1;
    Number = (INT8 *)Hal_Mem_Alloc(Len);
    Hal_Mem_Copy(Number, Contact->Number, Len);

    Contacts_SMS_Req(Name, Number);
}

/**
 * Action if pressing ring tone button on Contacts_Details_Option interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Option_Btn_Ring_Tone_Cb(lv_obj_t *Btn,lv_event_t event)
{
#if 0
    UINT8 Memory = Contacts_Get_Contact_Memory(
        g_ContactsMng.InterfaceCtrl.ContactDetail->MemoryAndIndex);

    if (  (CONTACTS_MEMORY_SIM1 == Memory)
       || (CONTACTS_MEMORY_SIM2 == Memory))
    {
        Contacts_Create_Contacts_Ring_Tone_Not_Set();
    }
    else // if (CONTACTS_MEMORY_PHONE == Memory)
    {
        Contacts_Create_Contacts_Ring_Tone();
    }
#else
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Create_Contacts_Ring_Tone();
#endif
}

/**
 * Action if pressing share via SMS button on Contacts_Details_Option interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Option_Btn_Share_Via_Sms_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    INT8            *Name;
    INT8            *Number;
    UINT8           Len;
    Contacts_Info_t *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;

    Len  = strlen(Contact->Name) + 1;
    Name = (INT8 *)Hal_Mem_Alloc(Len);
    Hal_Mem_Copy(Name, Contact->Name, Len);

    Len    = strlen(Contact->Number) + 1;
    Number = (INT8 *)Hal_Mem_Alloc(Len);
    Hal_Mem_Copy(Number, Contact->Number, Len);

    Contacts_Share_Via_SMS_Req(Name, Number);
}

/**
 * Action if pressing copy contact button on Contacts_Details_Option interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Option_Btn_Copy_Contact_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Create_Contacts_Details_Copy();
}

/**
 * Action if pressing move contact button on Contacts_Details_Option interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Option_Btn_Move_Contact_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Create_Contacts_Details_Move();
}

/**
 * Action if pressing delete contact button on Contacts_Details_Option interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Option_Btn_Delete_Contact_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Create_Contacts_Details_Delete();
}

/**
 * Action if pressing add to number screening list button on Contacts_Details_Option interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Option_Btn_Add_To_Num_Scrn_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Info_t *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
    UINT8           i;
    UINT8           Len;

    for (i = 0; i < CONTACTS_MAX_NUM_SCRN_NUMBER; i++)
    {
        if ('\0' == g_ContactsMng.NumScrnList[i][0])
        {
            break;
        }
    }
    if (CONTACTS_MAX_NUM_SCRN_NUMBER == i)
    {
        Contacts_Create_Contacts_Num_Scrn_List_Full();
    }
    else
    {
        g_ContactsMng.InterfaceCtrl.SrcActId = ACT_ID_CONTACTS_DETAILS;
        Len                                  = strlen(Contact->Number) + 1;
        if (NULL != g_ContactsMng.InterfaceCtrl.Number)
        {
            UI_Log_Out(UI_SUB_MODULE_FRAMEWORK, UI_LOG_LEVEL_TRACE_1, "Warning! Contacts_Details_Option_Btn_Add_To_Num_Scrn_Cb, Number %s\n", g_ContactsMng.InterfaceCtrl.Number);
            Hal_Mem_Free(g_ContactsMng.InterfaceCtrl.Number);
            g_ContactsMng.InterfaceCtrl.Number = NULL;
        }

        g_ContactsMng.InterfaceCtrl.Number = (INT8 *)Hal_Mem_Alloc(Len);
        Hal_Mem_Copy(g_ContactsMng.InterfaceCtrl.Number, Contact->Number, Len);
        Contacts_Create_Contacts_Add_Num_Scrn();
    }
}

/**
 * Action if pressing delete from number screening list button on Contacts_Details_Option interface
 * param (in) lv_obj_t *Btn,lv_event_t event
 * return  void
 */
void Contacts_Details_Option_Btn_Del_From_Num_Scrn_Cb(lv_obj_t *Btn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Info_t *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
    UINT8           i;

    for (i = 0; i < CONTACTS_MAX_NUM_SCRN_NUMBER; i++)
    {
        if (0 == Contacts_Compare_Number(Contact->Number, g_ContactsMng.NumScrnList[i]))
        {
            break;
        }
    }

    if (CONTACTS_MAX_NUM_SCRN_NUMBER == i)
    {
        printf("%s: number %s\n", __FUNCTION__, Contact->Number);
    }

    g_ContactsMng.InterfaceCtrl.SrcActId = ACT_ID_CONTACTS_DETAILS;
    Contacts_Create_Contacts_Noscreen_Delete(i);
}

/**
 * Callback function for additional actions after Creating Contacts_Details_Option interface
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Details_Option_OnCreate(VOID *Ctrl)
{
    UI_Normal_List_Only_Desc_t *Interface = (UI_Normal_List_Only_Desc_t *)Ctrl;
    lv_obj_t                   *Label     = Interface->TitleBar.Label;

    lv_label_set_text(Label, g_ContactsMng.InterfaceCtrl.ContactDetail->Name);
}

/**
 * Callback function for restoring state on Contacts_Details_Option interface after backward from another activity
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Details_Option_OnRestoreState(VOID *Ctrl)
{
    UI_Normal_List_Only_Desc_t *Interface = (UI_Normal_List_Only_Desc_t *)Ctrl;
    lv_obj_t                   *Label     = Interface->TitleBar.Label;

    g_ContactsMng.InterfaceCtrl.Ctrl        = Ctrl;
    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS_OPTION;

    lv_label_set_text(Label, g_ContactsMng.InterfaceCtrl.ContactDetail->Name);
}

/**
 * Create Contacts_Details_Option interface
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Create_Contacts_Details_Option(VOID)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc;
    Nav_Func_List_t            FuncList;
    UINT8                      i = 0;
    UINT8                      j;
    Contacts_Info_t            *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
    UINT32                     Len;
    UINT8                      NumLen = strlen(Contact->Number);

    NormalLstOnlyDesc =
        (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(NormalLstOnlyDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS_OPTION;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)NormalLstOnlyDesc;

    NormalLstOnlyDesc->TitleBar.TxtId      = LV_LANG_TXT_ID_NONE;
    NormalLstOnlyDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    NormalLstOnlyDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    if (0 < NumLen)
    {
        NormalLstOnlyDesc->List.ListButtonCnt += 2; // ring tone & number screening
    }
    if ((CONTACTS_PHONEBOOK_STATUS_READ_DONE == g_ContactsMng.PhonebookStatus[0])
        || (CONTACTS_PHONEBOOK_STATUS_READ_DONE == g_ContactsMng.PhonebookStatus[1]))
    {   /* SIM present */
        if (0 < NumLen)
        {
            NormalLstOnlyDesc->List.ListButtonCnt += 4; // call & SMS & copy & move
        }
        NormalLstOnlyDesc->List.ListButtonCnt += 1; // share via sms
    }
    NormalLstOnlyDesc->List.ListButtonCnt += 1; // delete
    Len = sizeof(UI_Button_Desc_t) *
          NormalLstOnlyDesc->List.ListButtonCnt;
    NormalLstOnlyDesc->List.ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(Len);
    Hal_Mem_Set(NormalLstOnlyDesc->List.ButtonList, 0, Len);

    if (((CONTACTS_PHONEBOOK_STATUS_READ_DONE == g_ContactsMng.PhonebookStatus[0])
         || (CONTACTS_PHONEBOOK_STATUS_READ_DONE == g_ContactsMng.PhonebookStatus[1]))
        && (0 < NumLen))
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_CALL;
        NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun = Contacts_Details_Option_Btn_Call_Cb;

        NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_SEND_SMS;
        NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun =
            Contacts_Details_Option_Btn_Send_Message_Cb;
    }

    if (0 < NumLen)
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_RINGING_TONE;
        NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun = Contacts_Details_Option_Btn_Ring_Tone_Cb;
    }

    if ((CONTACTS_PHONEBOOK_STATUS_READ_DONE == g_ContactsMng.PhonebookStatus[0])
        || (CONTACTS_PHONEBOOK_STATUS_READ_DONE == g_ContactsMng.PhonebookStatus[1]))
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_SHARE_VIA_SMS;
        NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun =
            Contacts_Details_Option_Btn_Share_Via_Sms_Cb;

        if (0 < NumLen)
        {
            NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
            NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
            NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_COPY;
            NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun =
                Contacts_Details_Option_Btn_Copy_Contact_Cb;

            NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
            NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
            NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_MOVE;
            NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun =
                Contacts_Details_Option_Btn_Move_Contact_Cb;
        }
    }

    NormalLstOnlyDesc->List.ButtonList[i].Valid        = TRUE;
    NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex  = i;
    NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_DELETE;
    NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun =
        Contacts_Details_Option_Btn_Delete_Contact_Cb;

    if (0 < NumLen)
    {
        NormalLstOnlyDesc->List.ButtonList[i].Valid       = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex = i;
        for (j = 0; j < CONTACTS_MAX_NUM_SCRN_NUMBER; j++)
        {
            if (0 == Contacts_Compare_Number(Contact->Number, g_ContactsMng.NumScrnList[j]))
            {
                NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_DEL_FROM_SCRLIST;
                NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun =
                    Contacts_Details_Option_Btn_Del_From_Num_Scrn_Cb;
                break;
            }
        }
        if (CONTACTS_MAX_NUM_SCRN_NUMBER == j)
        {
            NormalLstOnlyDesc->List.ButtonList[i].TxtId        = PHONE_TEXT_ID_ADD_TO_SL;
            NormalLstOnlyDesc->List.ButtonList[i++].ReleaseFun =
                Contacts_Details_Option_Btn_Add_To_Num_Scrn_Cb;
        }
    }

    NormalLstOnlyDesc->BtnBar.ButtonL.Valid = FALSE;
    NormalLstOnlyDesc->BtnBar.ButtonM.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    NormalLstOnlyDesc->BtnBar.ButtonR.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalLstOnlyDesc->KeyFunc = Contacts_Normal_List_Interface_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Normal_List_Only_Create;
    FuncList.OnCreate       = Contacts_Details_Option_OnCreate;
    FuncList.OnSaveState    = Contacts_Interface_OnSaveState;
    FuncList.OnRestoreState = Contacts_Details_Option_OnRestoreState;
    FuncList.OnDestroy      = Contacts_Normal_List_Interface_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_DETAILS_OPTION, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
} /* Contacts_Create_Contacts_Details_Option */

/**
 * Create Contacts_Edit_Warning interface
 * param (in) TxtId: UINT16
 * return  VOID
 */
VOID Contacts_Create_Contacts_Edit_Warning(UINT16 TxtId)
{
    UI_Status_Desc_t *StatusDesc;
    Nav_Func_List_t  FuncList;

    StatusDesc = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(StatusDesc, 0, sizeof(UI_Status_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_EDIT_WARNING;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)StatusDesc;

    StatusDesc->ContLabel.TxtId      = TxtId;
    StatusDesc->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    StatusDesc->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    StatusDesc->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    StatusDesc->ContImg.Img  = LV_SYMBOL_WARNING;
    StatusDesc->ContImgAlign = LV_ALIGN_IN_TOP_RIGHT;

    StatusDesc->KeyFunc = Contacts_Status_Interface_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Status_Create;
    FuncList.OnCreate  = Contacts_Status_Interface_OnCreate;
    FuncList.OnDestroy = Contacts_Interface_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_EDIT_WARNING, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
}

VOID Contacts_Edit_Handle_Key_Ok(UI_Container_Base_Desc_t *ContList)
{
    lv_obj_t                       *Ta;
    INT8                           *Name;
    INT8                           *Number;
    UINT8                          Len;
    Contacts_List_t                *Contact;
    Contacts_Info_t                *ContactInfo;
    UINT16                         Index;
    UINT32                         Offset;
    NV_UI_Contacts_Contact_Info_t  NvContact;
    UINT8                          Memory;
    lv_ll_t                        *ContactsList;

    /* get contact name */
    Ta   = ContList[0].u.Ta.TextArea;
    Name = (INT8 *)lv_textarea_get_text(Ta);
    if (0 == strlen(Name)) // no name
    {
        Contacts_Create_Contacts_Edit_Warning(PHONE_TEXT_ID_NO_NAME_NUMBER);
        return;
    }

    Ta     = ContList[1].u.Ta.TextArea;
    Number = (INT8 *)lv_textarea_get_text(Ta);
    if (0 == strlen(Number)) // no number
    {
        Contacts_Create_Contacts_Edit_Warning(PHONE_TEXT_ID_NO_NAME_NUMBER);
        return;
    }

    ContactInfo = g_ContactsMng.InterfaceCtrl.ContactDetail;
    Memory      = Contacts_Get_Contact_Memory(ContactInfo->MemoryAndIndex);
    Index       = Contacts_Get_Contact_Index(ContactInfo->MemoryAndIndex);

    g_ContactsMng.InterfaceCtrl.SrcActId = ACT_ID_CONTACTS_DETAILS;

    if (0 == strcmp(Name, ContactInfo->Name))
    {
        Name = NULL;
    }
    if (0 == strcmp(Number, ContactInfo->Number))
    {
        Number = NULL;
    }

    if ((NULL == Name) && (NULL == Number))
    {
        if (CONTACTS_MEMORY_PHONE == Memory)
        {
            Contacts_Create_Contacts_Saved(PHONE_TEXT_ID_CONTACT_SAVED_PHONE);
        }
        else if (CONTACTS_MEMORY_SIM1 == Memory)
        {
            Contacts_Create_Contacts_Saved(PHONE_TEXT_ID_CONTACT_SAVED_SIM1);
        }
        else if (CONTACTS_MEMORY_SIM2 == Memory)
        {
            Contacts_Create_Contacts_Saved(PHONE_TEXT_ID_CONTACT_SAVED_SIM2);
        }
    }
    else
    {
        Contacts_Speed_Dials_Update_Contact(ContactInfo, Name, Number);

        if (Name)
        {
            ContactInfo = (Contacts_Info_t *)Hal_Mem_Alloc(sizeof(Contacts_Info_t));
            Hal_Mem_Copy(ContactInfo, g_ContactsMng.InterfaceCtrl.ContactDetail, sizeof(Contacts_Info_t));
        }
        else
        {
            ContactInfo = g_ContactsMng.InterfaceCtrl.ContactDetail;
        }

        if (Number)
        {
            Hal_Mem_Set(ContactInfo->Number, 0, CONTACTS_MAX_NUMBER_LENGTH);
            Hal_Mem_Copy(ContactInfo->Number, Number, strlen(Number));
        }
        if (Name)
        {
            Hal_Mem_Set(ContactInfo->Name, 0, CONTACTS_MAX_NAME_LENGTH);
            Hal_Mem_Copy(ContactInfo->Name, Name, strlen(Name));

            Contact = NULL;
            if (0 == Contacts_Add_Contact(ContactInfo, NULL, &Contact))
            {
                Hal_Mem_Free(ContactInfo);
                Contacts_Create_Contacts_Edit_Warning(PHONE_TEXT_ID_NAME_ALREADY_EXISTS);
                return;
            }

            g_ContactsMng.InterfaceCtrl.FocusContact = Contact;

            /* delete old contact in the contact lists */
            ContactsList = &g_ContactsMng.ContactsList;
            Contact      = _lv_ll_get_head(ContactsList);
            while (NULL != Contact)
            {
                if (g_ContactsMng.InterfaceCtrl.ContactDetail == Contact->ContactInfo)
                {
                    _lv_ll_remove(ContactsList, Contact);
                    Hal_Mem_Free(Contact);
                    g_ContactsMng.ContactsCount--;
                    break;
                }
                Contact = _lv_ll_get_next(ContactsList, Contact);
            }
            if (CONTACTS_MEMSEL_ALL != g_ContactsMng.ContactsMemSel.MemSel)
            {
                ContactsList = &g_ContactsMng.ContactsMemSel.ListForSpecMem;
                Contact      = _lv_ll_get_head(ContactsList);
                while (NULL != Contact)
                {
                    if (g_ContactsMng.InterfaceCtrl.ContactDetail == Contact->ContactInfo)
                    {
                        _lv_ll_remove(ContactsList, Contact);
                        Hal_Mem_Free(Contact);
                        g_ContactsMng.ContactsMemSel.ContactsCount--;
                        break;
                    }
                    Contact = _lv_ll_get_next(ContactsList, Contact);
                }
            }

            Hal_Mem_Free(g_ContactsMng.InterfaceCtrl.ContactDetail);
            g_ContactsMng.InterfaceCtrl.ContactDetail = ContactInfo;

        }
        Contacts_Update_Contacts_Interface();

        if (CONTACTS_MEMORY_PHONE == Memory)
        {
            Hal_Mem_Copy(NvContact.Name, ContactInfo->Name, CONTACTS_MAX_NAME_LENGTH);
            Hal_Mem_Copy(NvContact.Number, ContactInfo->Number, CONTACTS_MAX_NUMBER_LENGTH);
            NvContact.ToneIndex = ContactInfo->ToneIndex;
            Len                 = sizeof(NV_UI_Contacts_Contact_Info_t);
            Offset              = Len * Index;
            if (Len !=
                UI_NV_Write_Req(NV_SECTION_UI_CONTACTS_LIST, Offset, Len, (UINT8 *)(&NvContact)))
            {
                /* error */
                return;
            }

            Contacts_Create_Contacts_Saved(PHONE_TEXT_ID_CONTACT_SAVED_PHONE);
        }
        else
        {
            /*at first delete old contact in SIM*/
            g_ContactsMng.ContactOper.Action = CONTACTS_ACTION_EDIT_PHASE_1;

            Contacts_Send_Write_Phonebook_Req(Memory, NULL, NULL, Index);
        }
    }
}

VOID Contacts_Edit_Handle_Key_Up_Down(UI_KEY_VALUE Key_Val,
                                      UI_Normal_Container_List_Desc_t *Interface,
                                      UI_Container_Base_Desc_t *ContList,
                                      lv_obj_t *Ta)
{
    lv_textarea_set_cursor_hidden(Ta, TRUE);

    if (0 == Interface->ContList.Index)
    {
        Interface->ButtonBar.ButtonL.ButtonIndex = Ime_Get_Mode();
    }

    if (KEY_UP == Key_Val)
    {
        if (0 == Interface->ContList.Index)
        {
            Interface->ContList.Index = Interface->ContList.ListContainerCnt - 1;
        }
        else
        {
            Interface->ContList.Index--;
        }
    }
    else
    {
        if ((Interface->ContList.ListContainerCnt - 1) == Interface->ContList.Index)
        {
            Interface->ContList.Index = 0;
        }
        else
        {
            Interface->ContList.Index++;
        }
    }

    if (0 == Interface->ContList.Index)
    {
        Ime_Set_SingleMode(FALSE);
        Ime_Set_Mode(Interface->ButtonBar.ButtonL.ButtonIndex);
    }
    else if (1 == Interface->ContList.Index)
    {
        Ime_Set_Mode(LV_IME_MODE_NUM);
        Ime_Set_SingleMode(TRUE);
    }

    Ta = ContList[Interface->ContList.Index].u.Ta.TextArea;
    lv_textarea_set_cursor_hidden(Ta, FALSE);

}


/**
 * Callback function for handling key pressed on Contacts_Edit interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
UINT8 Contacts_Edit_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UI_Normal_Container_List_Desc_t *Interface =
        (UI_Normal_Container_List_Desc_t *)g_ContactsMng.InterfaceCtrl.Ctrl;
    UI_Container_Base_Desc_t *ContList = Interface->ContList.ContainerList;
    lv_obj_t                 *Ta       = ContList[Interface->ContList.Index].u.Ta.TextArea;
    UINT8                    Ret       = 1;
    INT8                     Char      = 0;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTLEFT: // back
            Nav_Back(ACT_ID_ANY);
            break;

        case KEY_SOFTRIGHT: // clear
            lv_textarea_del_char(Ta);
            break;

        case KEY_0:
        case KEY_1:
        case KEY_2:
        case KEY_3:
        case KEY_4:
        case KEY_5:
        case KEY_6:
        case KEY_7:
        case KEY_8:
        case KEY_9:
        case KEY_ASTERISK:
        case KEY_HASH:
            if (KEY_ASTERISK == Key_Val)
            {
                Char = '*';
            }
            else if (KEY_HASH == Key_Val)
            {
                Char = '#';
            }
            else
            {
                Char = Key_Val - KEY_0 + '0';
            }
            lv_textarea_add_char(Ta, Char);

            if (0 == Interface->ContList.Index)
            {
                Contacts_Input_Handler(0);
                break;
            }
            break;

        case KEY_UP:
        case KEY_DOWN:
            Contacts_Edit_Handle_Key_Up_Down(Key_Val, Interface, ContList, Ta);
            Ret = 0;
            break;

        case KEY_LEFT:
            lv_textarea_cursor_left(Ta);
            break;

        case KEY_RIGHT:
            lv_textarea_cursor_right(Ta);
            break;

        case KEY_OK: // Save
            Contacts_Edit_Handle_Key_Ok(ContList);
            break;

        case KEY_END:
            Nav_Home(ACT_ID_ANY);
            break;

        default:
            break;
        } /* switch */
    }

    return(Ret);
} /* Contacts_Edit_Key_Cb */

/**
 * Callback function for additional actions after Creating Contacts_Edit interface
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Edit_OnCreate(VOID *Ctrl)
{
    UI_Normal_Container_List_Desc_t *Interface = (UI_Normal_Container_List_Desc_t *)Ctrl;
    UI_Container_Base_Desc_t        *ContList  = Interface->ContList.ContainerList;
    lv_obj_t                        *Ta;

    Ta = ContList[0].u.Ta.TextArea;
    g_ContactsMng.ContactOper.DestMemory
        = Contacts_Get_Contact_Memory(g_ContactsMng.InterfaceCtrl.ContactDetail->MemoryAndIndex);
    if (CONTACTS_MEMORY_PHONE == g_ContactsMng.ContactOper.DestMemory)
    {
        lv_textarea_set_max_length(Ta, CONTACTS_MAX_NAME_LENGTH - 1);
    }
    else
    {
        /*dynamically calculate the maximum length of text on TA
         *after input or delete for SIM1 or SIM2*/
        lv_textarea_set_max_length(Ta, 0);
        Ime_Set_GetCharLen_Func(Contacts_Input_Handler);
    }
    Ime_Set_SingleMode(FALSE);

    Ta = ContList[1].u.Ta.TextArea;
    lv_textarea_set_max_length(Ta, CONTACTS_MAX_NUMBER_LENGTH - 1);
}

/**
 * Callback function for saving state on Contacts_Edit interface before forward to another activity
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Edit_OnSaveState(VOID *Ctrl)
{
    UI_Normal_Container_List_Desc_t *Interface = (UI_Normal_Container_List_Desc_t *)Ctrl;
    UI_Container_Base_Desc_t        *ContList  = Interface->ContList.ContainerList;
    lv_obj_t                        *Ta;
    const INT8                      *Text;
    UINT8                           Len;

    Ta   = ContList[0].u.Ta.TextArea;
    Text = lv_textarea_get_text(Ta);
    if (0 != strlen(ContList[0].u.Ta.TaTxt))
    {
        Hal_Mem_Free(ContList[0].u.Ta.TaTxt);
        ContList[0].u.Ta.TaTxt = NULL;
    }
    Len = strlen(Text);
    if (0 != Len)
    {
        Len++;
        ContList[0].u.Ta.TaTxt = (INT8 *)Hal_Mem_Alloc(Len);
        Hal_Mem_Copy(ContList[0].u.Ta.TaTxt, (INT8 *)Text, Len);
    }
    else
    {
        ContList[0].u.Ta.TaTxt = "";
    }

    Ta   = ContList[1].u.Ta.TextArea;
    Text = lv_textarea_get_text(Ta);
    if (0 != strlen(ContList[1].u.Ta.TaTxt))
    {
        Hal_Mem_Free(ContList[1].u.Ta.TaTxt);
        ContList[1].u.Ta.TaTxt = NULL;
    }
    Len = strlen(Text);
    if (0 != Len)
    {
        Len++;
        ContList[1].u.Ta.TaTxt = (INT8 *)Hal_Mem_Alloc(Len);
        Hal_Mem_Copy(ContList[1].u.Ta.TaTxt, (INT8 *)Text, Len);
    }
    else
    {
        ContList[1].u.Ta.TaTxt = "";
    }

    if (0 == Interface->ContList.Index)
    {
        Interface->ButtonBar.ButtonL.ButtonIndex = Ime_Get_Mode();
    }
} /* Contacts_Edit_OnSaveState */

/**
 * Callback function for restoring state on Contacts_Edit interface after backward from another activity
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Edit_OnRestoreState(VOID *Ctrl)
{
    UI_Normal_Container_List_Desc_t *Interface = (UI_Normal_Container_List_Desc_t *)Ctrl;
    UI_Container_Base_Desc_t        *ContList  = Interface->ContList.ContainerList;
    lv_obj_t                        *Ta;

    g_ContactsMng.InterfaceCtrl.Ctrl        = Ctrl;
    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_EDIT;

    Ta = ContList[0].u.Ta.TextArea;
    g_ContactsMng.ContactOper.DestMemory = Contacts_Get_Contact_Memory(
        g_ContactsMng.InterfaceCtrl.ContactDetail->MemoryAndIndex);
    if (CONTACTS_MEMORY_PHONE == g_ContactsMng.ContactOper.DestMemory)
    {
        lv_textarea_set_max_length(Ta, CONTACTS_MAX_NAME_LENGTH - 1);
    }
    else
    {
        /*dynamically calculate the maximum length of text on TA
         *after input or delete for SIM1 or SIM2*/
        lv_textarea_set_max_length(Ta, 0);
        Ime_Set_GetCharLen_Func(Contacts_Input_Handler);
    }
    if (0 != Interface->ContList.Index)
    {
        lv_textarea_set_cursor_hidden(Ta, TRUE);
    }
    else
    {
        Ime_Set_SingleMode(FALSE);
    }

    Ta = ContList[1].u.Ta.TextArea;
    lv_textarea_set_max_length(Ta, CONTACTS_MAX_NUMBER_LENGTH - 1);
    if (1 == Interface->ContList.Index)
    {
        Ime_Set_Mode(LV_IME_MODE_NUM);
        Ime_Set_SingleMode(TRUE);
        lv_textarea_set_cursor_hidden(Ta, FALSE);
    }
}

/**
 * Callback function for destroying Contacts_Edit interface which will be popped from stack
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Edit_OnDestroy(VOID *Ctrl)
{
    UI_Normal_Container_List_Desc_t *Interface = (UI_Normal_Container_List_Desc_t *)Ctrl;
    UI_Container_Base_Desc_t        *ContList  = Interface->ContList.ContainerList;

    if (0 != strlen(ContList[0].u.Ta.TaTxt))
    {
        Hal_Mem_Free(ContList[0].u.Ta.TaTxt);
        ContList[0].u.Ta.TaTxt = NULL;
    }
    if (0 != strlen(ContList[1].u.Ta.TaTxt))
    {
        Hal_Mem_Free(ContList[1].u.Ta.TaTxt);
        ContList[1].u.Ta.TaTxt = NULL;
    }
    Hal_Mem_Free(Interface->ContList.ContainerList);
    Hal_Mem_Free(Ctrl);

    g_ContactsMng.ContactOper.DestMemory = 0;
}

/**
 * Create Contacts_Edit interface
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Create_Contacts_Edit(VOID)
{
    UI_Normal_Container_List_Desc_t *Interface;
    UI_Container_Base_Desc_t        *ContList;
    Nav_Func_List_t                 FuncList;
    UINT8                           Len;
    Contacts_Info_t                 *Contact;

    if (NULL == g_ContactsMng.InterfaceCtrl.ContactDetail)
    {
        /* error */
        return;
    }
    Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;

    Interface =
        (UI_Normal_Container_List_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(Interface, 0, sizeof(UI_Normal_Container_List_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_EDIT;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)Interface;

    Interface->TitleBar.TxtId      = PHONE_TEXT_ID_CONTACT;
    Interface->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    Interface->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    Interface->ContList.ListContainerCnt = 2;
    Interface->ContList.ContainerList    =
        (UI_Container_Base_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Container_Base_Desc_t) * Interface->ContList.ListContainerCnt);
    ContList = Interface->ContList.ContainerList;
    Hal_Mem_Set(ContList, 0, sizeof(UI_Container_Base_Desc_t) * Interface->ContList.ListContainerCnt);

    ContList[0].Valid             = TRUE;
    ContList[0].Label.TxtId       = PHONE_TEXT_ID_NAMES;
    ContList[0].Label.TxtAlign    = LV_LABEL_ALIGN_LEFT;
    ContList[0].Label.LabelAlign  = LV_ALIGN_IN_TOP_LEFT;
    ContList[0].Choise            = UI_BASE_OBJ_TA;
    ContList[0].u.Ta.TaCursorHide = FALSE;
    ContList[0].u.Ta.TaAlign      = LV_ALIGN_IN_BOTTOM_LEFT;
    Len                           = strlen(Contact->Name) + 1;
    ContList[0].u.Ta.TaTxt        = (INT8 *)Hal_Mem_Alloc(Len);
    Hal_Mem_Copy(ContList[0].u.Ta.TaTxt, Contact->Name, Len);
    ContList[0].ReleaseFunc       = NULL;

    ContList[1].Valid             = TRUE;
    ContList[1].Label.TxtId       = PHONE_TEXT_ID_NUMBERS;
    ContList[1].Label.TxtAlign    = LV_LABEL_ALIGN_LEFT;
    ContList[1].Label.LabelAlign  = LV_ALIGN_IN_TOP_LEFT;
    ContList[1].Choise            = UI_BASE_OBJ_TA;
    ContList[1].u.Ta.TaCursorHide = TRUE;
    ContList[1].u.Ta.TaAlign      = LV_ALIGN_IN_BOTTOM_LEFT;
    Len                           = strlen(Contact->Number) + 1;
    ContList[1].u.Ta.TaTxt        = (INT8 *)Hal_Mem_Alloc(Len);
    Hal_Mem_Copy(ContList[1].u.Ta.TaTxt, Contact->Number, Len);
    ContList[1].ReleaseFunc       = NULL;

    Interface->ButtonBar.ButtonL.Valid = TRUE;
    Interface->ButtonBar.ButtonL.TxtId = PHONE_TEXT_ID_BACK;
    Interface->ButtonBar.ButtonM.Valid = TRUE;
    Interface->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_SAVE;
    Interface->ButtonBar.ButtonR.Valid = TRUE;
    Interface->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;

    Interface->KeyFunc = Contacts_Edit_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Normal_Container_List_Create;
    FuncList.OnCreate       = Contacts_Edit_OnCreate;
    FuncList.OnSaveState    = Contacts_Edit_OnSaveState;
    FuncList.OnRestoreState = Contacts_Edit_OnRestoreState;
    FuncList.OnDestroy      = Contacts_Edit_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_EDIT, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
} /* Contacts_Create_Contacts_Edit */

/**
 * Callback function for handling key pressed on Contacts_Details interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
UINT8 Contacts_Details_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    INT8            *Name;
    INT8            *Number;
    UINT8           Len;
    Contacts_Info_t *Contact;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTLEFT:
            Contacts_Create_Contacts_Details_Option();
            break;

        case KEY_SOFTRIGHT:
            Nav_Back(ACT_ID_ANY);
            break;

        case KEY_END:
            Nav_Home(ACT_ID_ANY);
            break;

        case KEY_OK: // edit
            Contacts_Create_Contacts_Edit();
            break;

        case KEY_DIAL:
            Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;
            Len = strlen(Contact->Number);
            if (0 == Len)
            {
                Contacts_Create_No_Phone_Number();
                break;
            }
            Len++;
            Number = (INT8 *)Hal_Mem_Alloc(Len);
            Hal_Mem_Copy(Number, Contact->Number, Len);

            Len  = strlen(Contact->Name) + 1;
            Name = (INT8 *)Hal_Mem_Alloc(Len);
            Hal_Mem_Copy(Name, Contact->Name, Len);

            Contacts_Call_Req(Name, Number);
            break;

        default:
            break;
        } /* switch */
    }

    return(1);
} /* Contacts_Details_Key_Cb */

/**
 * Callback function for additional actions after Creating Contacts_Details interface
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Details_OnCreate(VOID *Ctrl)
{
    UI_Normal_Label_Only_Desc_t *Interface = (UI_Normal_Label_Only_Desc_t *)Ctrl;
    lv_obj_t                    *Label     = Interface->ContLabel.Label;
    UINT8                       Len;
    INT8                        *Output;
    Contacts_Info_t             *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;

    Len    = strlen(Contact->Name) + 1 + strlen(Contact->Number) + 1;
    Output = (INT8 *)Hal_Mem_Alloc(Len);
    sprintf(Output, "%s\n%s", Contact->Name, Contact->Number);
    lv_label_set_text(Label, Output);
    Hal_Mem_Free(Output);
}

/**
 * Callback function for restoring state on Contacts_Details interface after backward from another activity
 * param (in) Ctrl: VOID *
 * return  VOID
 */
VOID Contacts_Details_OnRestoreState(VOID *Ctrl)
{
    UI_Normal_Label_Only_Desc_t *Interface = (UI_Normal_Label_Only_Desc_t *)Ctrl;
    lv_obj_t                    *Label     = Interface->ContLabel.Label;
    UINT8                       Len;
    INT8                        *Output;
    Contacts_Info_t             *Contact = g_ContactsMng.InterfaceCtrl.ContactDetail;

    g_ContactsMng.InterfaceCtrl.Ctrl        = Ctrl;
    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS;

    Len    = strlen(Contact->Name) + 1 + strlen(Contact->Number) + 1;
    Output = (INT8 *)Hal_Mem_Alloc(Len);
    sprintf(Output, "%s\n%s", Contact->Name, Contact->Number);
    lv_label_set_text(Label, Output);
    Hal_Mem_Free(Output);
}

/**
 * Create Contacts_Details interface
 * param (in) Contact: Contacts_Info_t *
 * param (in) BackToContacts: BOOL
 * return  VOID
 */
VOID Contacts_Create_Contacts_Details(Contacts_Info_t *Contact, BOOL BackToContacts)
{
    UI_Normal_Label_Only_Desc_t *Interface;
    Nav_Func_List_t             FuncList;

    if (NULL == Contact)
    {
        /* error */
        return;
    }
    g_ContactsMng.InterfaceCtrl.ContactDetail = Contact;

    Interface = (UI_Normal_Label_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Label_Only_Desc_t));
    Hal_Mem_Set(Interface, 0, sizeof(UI_Normal_Label_Only_Desc_t));

    g_ContactsMng.InterfaceCtrl.InterfaceId = ACT_ID_CONTACTS_DETAILS;
    g_ContactsMng.InterfaceCtrl.Ctrl        = (VOID *)Interface;

    Interface->TitleBar.TxtId      = PHONE_TEXT_ID_CONTACT;
    Interface->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    Interface->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    Interface->ContLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    Interface->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    Interface->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    Interface->ButtonBar.ButtonL.Valid = TRUE;
    Interface->ButtonBar.ButtonL.TxtId = PHONE_TEXT_ID_OPT;
    Interface->ButtonBar.ButtonM.Valid = TRUE;
    Interface->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_EDIT;
    Interface->ButtonBar.ButtonR.Valid = TRUE;
    Interface->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    Interface->KeyFunc = Contacts_Details_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Normal_Label_Only_Create;
    FuncList.OnCreate       = Contacts_Details_OnCreate;
    FuncList.OnSaveState    = Contacts_Interface_OnSaveState;
    FuncList.OnRestoreState = Contacts_Details_OnRestoreState;
    FuncList.OnDestroy      = Contacts_Interface_OnDestroy;

    if (FALSE == BackToContacts)
    {
        Nav_Forward(ACT_ID_ANY, ACT_ID_CONTACTS_DETAILS, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
    }
    else // delete Contacts_Search interface from nav stack
    {
        Nav_Backward_And_Forward(ACT_ID_ANY, ACT_ID_CONTACTS, ACT_ID_CONTACTS_DETAILS, &FuncList, g_ContactsMng.InterfaceCtrl.Ctrl);
    }
} /* Contacts_Create_Contacts_Details */
